import {Button } from 'antd'
import {useState,useMemo} from 'react'

/*
  1、 子组件什么时候渲染
  2、 子组件什么时候重新渲染
  3、 减少子组件的重新渲染
*/

const Child = ({name})=>{
	console.count("子组件渲染")
	return(
		<div>
			<h2>子组件</h2>
			<h3>name:{name}</h3>
		</div>
    )
}

/*
// const NewChilid = useMemo(()=>{
// 	return 3
// })

*/

const Father = ()=>{
	const [age,setAge] = useState(2)
	const [name,setName] = useState("小毅")
	console.count("父组件渲染")

	const handerClick = ()=>{
		console.log("点击		")
		setAge(age=> age=age+1)
	}

  return(
  	<div>
			<h2>父组件</h2>
			<h3>age：{age}</h3>
			<Button onClick={handerClick} type="primary">按钮</Button>
			<hr />
			<Child age={age} name={name} />

  	</div>
  	)
}


export {
	Child,
	Father
}